package com.song.exception;

import com.song.result.Result;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @program: untitled1
 * @ClassName UnifiedException
 * @description:
 * @author: Song
 * @create: 2025−01-03 15:35
 * @Version 1.0
 **/
@Component
@RestControllerAdvice //给controller 添加try catch
public class UnifiedException {

    @ExceptionHandler(value =Exception.class)
    public Result handlerException(Exception ex){

        System.out.println(ex.getMessage());
        ex.printStackTrace();

        return  Result.error();

    }
}
